//
//  RequestApi+User.m
//  MexicoLoan
//
//  Created by WXP on 2025/2/26.
//

#import "RequestApi+User.h"

@implementation RequestApi (User)

#pragma mark - 用户个人信息
+ (void)requestUserInformationWithDelegate:(id <RequestDelegate> _Nullable)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@",URL_HEAD,USER_BASEINFO] delegate:delegate parameters:nil success:^(NSDictionary *response, id mark) {
        [GlobalData sharedInstance].Global_ModelUser = [ModelUser modelObjectWithDictionary:response];
        if (success != nil) {
            success(response,mark);
        }
    } failure:failure];
}



#pragma mark - 获取客服信息
+ (void)requestCustomerServiceInfoWithDelegate:(id <RequestDelegate> _Nullable)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@",URL_HEAD,USER_CUSTOMERSERVICEINFO] delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 获取投诉信息
+ (void)requestComplaintPhoneWithDelegate:(id <RequestDelegate>)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@",URL_HEAD,COMMON_COMPLAINT_PHONE] delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 问题反馈
+ (void)requestComplaintWithTitle:(NSString *)title
                          content:(NSString *)content
                                    delegate:(id <RequestDelegate> _Nullable)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    NSDictionary * dic = @{
        KEY_title:   readStr(title),       // title - repoyarian
        KEY_content: readStr(content),  // content - latifundismos
    };
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@",URL_HEAD,USER_COMPLAINT] delegate:delegate parameters:dic success:success failure:failure];
}

#pragma mark - 获取首页需要的用户信用额度
+ (void)requestUserCreditInfoWithDelegate:(id <RequestDelegate>)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@",URL_HEAD,USER_CREDITINFO] delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 是否展示信用报告
+ (void)requestIsShowCREntranceWithPartnerId:(NSString *)partnerId
                                    pageType:(NSNumber *)pageType
                                    delegate:(id <RequestDelegate>)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    // pageType 1：首页 2：我的
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@?%@=%@&%@=%@",URL_HEAD,COMMON_IS_SHOW_CRENTRANCE,KEY_partnerId,partnerId,KEY_pageType,pageType] delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 信用报告分数
+ (void)requestCRSourceWithPartnerId:(NSString *)partnerId
                                    delegate:(id <RequestDelegate> _Nullable)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@?%@=%@&%@=%@",URL_HEAD, THIRD_CR_SOURCE, KEY_partnerId, partnerId, KEY_orderNo, [GlobalData sharedInstance].Global_UserCode] delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 是否展示FAQ
+ (void)requestIsShowFAQEntranceWithDelegate:(id <RequestDelegate>)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@",URL_HEAD, USER_ISSHOWFAQ] delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 首页弹窗信息
+ (void)requestCommonHomePopWithDelegate:(id <RequestDelegate> _Nullable)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@",URL_HEAD, COMMON_HOME_POP] delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 银行卡列表
+ (void)requestBankCardListWithDelegate:(id <RequestDelegate> _Nullable)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    [RequestApi postUrl:[NSString stringWithFormat:@"%@%@",URL_HEAD,USER_BANK_CARD_LIST2] delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 获取修改银行卡认证步骤接口
+ (void)requestAuthModifyStepsWithDelegate:(id <RequestDelegate>)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    NSString * url = [NSString stringWithFormat:@"%@%@",URL_HEAD, AUTH_GET_MODIFY_STEPS];
    [RequestApi postUrl:url delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 校验原银行卡接口
+ (void)requestCheckOldBankCard:(NSString *)bankCard
                              delegate:(id <RequestDelegate> _Nullable)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    NSString * url = [NSString stringWithFormat:@"%@%@?%@=%@",URL_HEAD, AUTH_CHECK_ORIGIN_BANK_CARD,KEY_bankCard,readStr(bankCard)];
    [RequestApi postUrl:url delegate:delegate parameters:nil success:success failure:failure];
}

#pragma mark - 修改银行卡
+ (void)requestModifyBankCardWithVcode:(NSString *)vcode
                                  step:(NSString *)step
                              bankCode:(NSString *)bankCode
                              bankCard:(NSString *)bankCard
                              bankName:(NSString *)bankName
                              delegate:(id <RequestDelegate>)delegate
                            success:(void (^)(NSDictionary * response, id mark))success
                            failure:(void (^)(NSString * errorStr, id mark))failure{
    
    NSDictionary * data = @{
        @"bankCode": readStr(bankCode),
        @"bankName": readStr(bankName),
        @"bankCard": readStr(bankCard),
    };
    NSString * dataStr = [GlobalMethod exchangeDicToJson:data];
    NSDictionary * dic = @{
        KEY_data: dataStr,       
        KEY_step: readStr(step),
        KEY_vcode: readStr(vcode)
    };
    NSString * url = [NSString stringWithFormat:@"%@%@",URL_HEAD, AUTH_MODIFY_BANK_CARD];
    [RequestApi postUrl:url delegate:delegate parameters:dic success:success failure:failure];
}


@end
